package com.yoyo.ad.utils;

import android.content.ContentResolver;
import android.content.Context;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

/**
 * create by huanzw
 */
public class TimeUtils {

    public static String getDate(long time) {
        return getDate(time, "yyyy-MM-dd");
    }

    public static String getDate(long time, String format) {
        SimpleDateFormat sf = new SimpleDateFormat(format, Locale.getDefault());
        return sf.format(time);
    }

    public static boolean isToday(long time) {
        long timeMillis = System.currentTimeMillis();
        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
        String sp_time = sf.format(time);
        String current_time = sf.format(timeMillis);
        return sp_time.equals(current_time);
    }

    public static boolean isToday(String time) {
        long timeMillis = System.currentTimeMillis();
        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
        String current_time = sf.format(timeMillis);
        return time.equals(current_time);
    }
}
